<?
/*
 * scrumbrella - Scrum board.
 *
 * Copyright (C) 2009  Gustavo N. Borgoni <gborgoni@voicemedia.com.ar>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

require_once("layout_config.php");
require_once("PHPTAL.php");

include("include/permission.php");
include("include/html_utils.php");
include("include/project.php");

// Check for user logged in
$user_id = permission_redirect_user("index.php");

if ($_SERVER['REQUEST_METHOD'] == "POST") {
	$summary     = $_REQUEST['pbacklog_summary'];
	$description = $_REQUEST['pbacklog_description'];
	$priority    = $_REQUEST['pbacklog_priority'];
	$user        = $_REQUEST['pbacklog_user'];
	$project     = $_REQUEST['project'];

	$res = project_backlog_add($project, $summary, $description, $user, $priority);
}

	// Load the template
	$temp = new PHPTAL('templates/projectbacklog_add.xhtml');
	
	// Various 
	$temp->id	   = $_SESSION['project'];
	$temp->theme 	   = "default";
	$temp->title 	   = _("New project");
	$temp->summary     = _("Summary");
	$temp->description = _("Description");
	$temp->priority	   = _("Priority");
	$temp->assignament = _("Assignament");

	// Save and cancel butons 
	$temp->bt_cancel   = _("Cancel");
	$temp->bt_save	   = _("Save");

	// Combo with user list
	$temp->users 	= html_select_userproject($_SESSION['project']);

	// Error msg
	$temp->summary_required = _("You must insert a summary");
	$temp->description_required   = _("You must insert a description");
	$temp->priority_required = _("You must insert a priority");
	$temp->user_required = _("You must select an user");

	try 
	{
		echo $temp->execute();
	}

	catch(Exception $e)
	{
		echo $e;
	}
?>
